package scau.erps.util;
import java.io.FileReader;
import java.io.FileWriter;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

import javax.swing.JOptionPane;

import com.ibatis.common.jdbc.ScriptRunner;
import com.ibatis.common.resources.Resources;
import com.mysql.jdbc.Connection;
public class DBcontrol {
 
 public static void reset() {
  
  try {
   String url = "jdbc:mysql://localhost:3306/erpsdb";
   String driver = "com.mysql.jdbc.Driver";
   String username = "root";
   String password = "123456";   
   Class.forName(driver).newInstance();
   ScriptRunner runner=new ScriptRunner(driver,url,username,password,false,false);
   runner.setErrorLogWriter(null);
   runner.setLogWriter(null);
   FileReader fileReader=new FileReader("doc/erpsdb.sql"); //读取文件路径
   runner.runScript(fileReader);   
   JOptionPane.showMessageDialog(null, "初始化完毕","提示",JOptionPane.INFORMATION_MESSAGE);
  } catch (Exception e) {
	  JOptionPane.showMessageDialog(null, e.getMessage(),"提示",JOptionPane.INFORMATION_MESSAGE);
  }
 }
 
 
}
